<template>
	<view class="container">
		<navbar :title="title"></navbar>
		<view class="wrap" v-if="showPage">
			<rich-text :nodes="content"></rich-text>
		</view>

	</view>
</template>

<script>
	const app = getApp();
	export default {
		data() {
			return {
				showPage: false,
				swiperId: '',
				title:'',
				content:''
			};
		},
		onLoad(option) {
			this.swiperId = option.id ? option.id : '';
			this.getDetail()
		},
		methods: {
			getDetail() {
				let that = this;
				uni.showLoading({
					title: '加载中...',
					mask: true
				})
				app.globalRequest({
					api: app.getApi().goodsdata.lunBoDetail,
					data: {
						id: that.swiperId
					}
				}).then(res => {
					that.showPage = true;
					if (res.code == 1) {
						that.title = res.data.detail.title;
						// const content = res.data.detail.content ? res.data.detail.content.replace(/\<img/gi,
						// 	'<img style="max-width:100%";display:block;height:auto') : '';
						// const regex = new RegExp('<img', 'gi');
						res.data.detail.content= res.data.detail.content.replace(/<img/gi, "<img class='richImg'")
						this.content = res.data.detail.content;
					}
				}).catch(err => {

				})
			}
		}
	}
</script>

<style>
	.richImg {
	    width: 100% !important;
	    height: auto !important;
		display: block !important;
	}
</style>
<style lang="scss" scoped>
	.wrap{
		margin:0 24rpx;
		padding-bottom: 100rpx;
	}
</style>